package com.mianshi;

import java.util.Stack;

public class tonghuashunmianshi {
    public static void main(String[] args) {
        String s = "<html><head><h1><h1></head><body><p>test</p></body></html>";
        char[] arr = s.toCharArray();
        Stack<String> stack = new Stack<>();
        boolean flag = true;
        boolean end = false;
        StringBuffer sb = new StringBuffer();
        for(int i = 0; i < arr.length; i++){
            char c = arr[i];
            if(end && c != '>'){
                sb.append(c);
                continue;
            }
            if(c == '<' ){
                if(!flag) flag = true;
                else sb.append(c);
            } else if(c == '>' && flag == true){
                if(end){
                    if(sb.toString().equals(stack.peek())){
                        stack.pop();
                    } else {
                        System.out.println("False");
                        return;
                    }
                }
                flag = false;
                sb.append(c);
                stack.push(sb.toString());
            } else if(c == '/' && flag == true){
                end = true;
            }
        }
        System.out.println("Yes");
    }


}
